﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using WindowsFormsApplication1.DTO;

namespace WindowsFormsApplication1.DAO
{
    class PhongDAO
    {
        public static List<PhongDTO> GetList()
        {
            SqlConnection ketNoi = AbstractDAO.Connection();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = ketNoi;
            cmd.CommandText = @"SELECT * FROM PHONG";

            // Thực thi câu lệnh 
            List<PhongDTO> ds = new List<PhongDTO>();
            SqlDataReader boDoc = cmd.ExecuteReader();
            while (boDoc.Read())
            {
                PhongDTO phong = new PhongDTO();
                phong.maPhong = boDoc.GetString(0);
                phong.tenPhong = boDoc.GetString(1);
                ds.Add(phong);
            }
            boDoc.Close();
            return ds;
        }
    }
}
